CC = gcc
CFLAGS = -Wall -Wextra -g  #open all warnings, add extra warnings, generate debug info
LDFLAGS = 
LDLIBS =
TARGET = httpd
SRCS = myhttpd.c test.c
OBJS = $(SRCS:.c=.o)
INCLUDES = -I ./include
DEFFILES = $(SRCS:.c=.d)

.PHONY: all clean

all: $(TARGET)
$(TARGET) : $(OBJS)
	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)
%.o : %.c
	$(CC) $(CFLAGS) -c -o $@ $<
%.d : %.c
	$(CC) $(CFLAGS) $(INCLUDES) -MM -MP $@ -MT $*.o $(CFLAGS) $< > $@ #-MM generate dependent relations, -MP generate phony target,-MT define the target type
-include $(DEPFILES)
clean:
	rm -f $(OBJS) $(TARGET) *.o
help:
	@echo "=====Makefile help======="
	@echo "make            : build target (default)"
	@echo "make clean      : clean all generated file"
	@echo "make help       : show this help info"
	


